package com.spring.utils.api_v4.controller.ui;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.spring.utils.api_v4.pojo.UserInfo;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotEmpty;

@Getter
@Setter
public class RoleItem {
    private String id;
    @NotEmpty(message = "用户不能为空")
    private String userId;
    @JsonIgnore
    private UserInfo userInfo;
    @NotEmpty(message = "角色名不能为空")
    private String name;

    public String getUserName() {
        if(userInfo != null) {
            return userInfo.getName();
        }
        return "";
    }

    public String getUserId() {
        if(userInfo != null){
            userId = userInfo.getId();
        }
        return userId;
    }
}
